package com.fanshuai.tree.trie.main;

import com.fanshuai.tree.trie.MultiWordTrie;
import com.fanshuai.tree.trie.Trie;
import com.fanshuai.tree.trie.WordToken;
import com.fanshuai.tree.trie.pinyin.PinyinTrie;

import java.util.Arrays;
import java.util.List;

public class Main {
    private static String[] words = new String[] {
            "毛泽东", "毛同志", "毛书记", "毛相林","媳评毛",
            "寻龙摸金","习书记","习老兄","习怂平","习zong",
            "啊扁涛哥","师父不要啊","大小单双技巧","大发云彩神","佣万一","徐洪兰",
            "凯迪社区","党员名单","195万名单","总射鸡师","坚夫莹妇","攘外必先安内"};

    private static String[] pinyinWords = new String[] {
            "毛泽东", "毛同志", "毛shuji", "毛相林","媳评毛",
            "寻龙摸金","习书记","习老兄","习怂平","习zong",
            "啊扁涛哥","师父不要啊","大小单@双技巧","大发 云彩神 12","佣万一","徐洪兰",
            "凯迪社区","党员名单","195万名单","总射鸡师","坚夫莹妇","攘外必先安内"};

    private static String[] multiWords = new String[] {
            "毛&泽东", "毛&&同志&", "毛&shuji", "毛相林","媳评毛",
            "寻龙摸金","习&书记&&","习&老兄","习怂平","习&zong",
            "啊扁涛哥","师父&不要啊","大小&单双&技巧&","大发 &云彩神 &12","佣万一","徐洪兰",
            "凯迪&社区","党员&名单","195万&名单","&总&射鸡师&","奸夫&淫妇","攘外必先&安内"};

    private static void TestTrie() {
        Trie trie = new Trie();
        trie.addWords(Arrays.asList(words));

        System.out.println(trie.getAllWords());
        System.out.println(trie.size());

        String text1 = "师父不要啊金  黄色的股份uidh党员名单习书记dfsdf地方毛同志坚夫莹妇";
        List<WordToken> tokens = trie.match(text1);
        System.out.println(tokens);
    }

    private static void TestPinyinTrie() {
        PinyinTrie pinyinTrie = new PinyinTrie();
        pinyinTrie.addWords(Arrays.asList(pinyinWords));

        List<String> words = pinyinTrie.getAllWords();
        System.out.println(words);
        System.out.println(pinyinTrie.size());

        String text1 = "shifu不要a金黄色的股份uidh当院名 旦xi书籍dfsdf地方毛tongzhijianfu应符";
        List<WordToken> tokens = pinyinTrie.match(text1);
        System.out.println(tokens);
    }

    private static void TestMultiTrie() {
        MultiWordTrie trie = new MultiWordTrie();
        trie.addWords(Arrays.asList(multiWords));

        List<String> words = trie.getAllWords();
        System.out.println(words);
        System.out.println(trie.size());

        String text1 = "师父dsd纠纷      不要啊金黄色的股份uidh党员名单习接待费    书记dfsdf地方毛纠纷      同志奸夫逗号     淫妇";
        List<WordToken> tokens = trie.match(text1);
        System.out.println(tokens);
    }

    public static void main(String[] args) {
        //TestTrie();
        //TestPinyinTrie();
        TestMultiTrie();
    }
}
